header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Pragma: no-cache"); // HTTP/1.0 /* * This file displays the derived data. It will retrieve all the * derived data that has been calculated from the database and print * it out in a table based on the cargo type and cargo that the user * has chosen. */ include "../voyagecalc/TShipCookie.php3"; include "../ads/ad.php"; /* DB attributes */ $dbname = "tshipping"; $dbhost = "www.tshipping.com"; $dbuser = "tshipping"; $dbpassword = "hytr5u7"; /* get a persistent connection to the database */ $db = pg_pconnect("dbname=$dbname host=$dbhost user=$dbuser password=$dbpassword"); /* cookie handling for moreover newsfeed output */ if ($tshippingFreeNewsPref == "soccer") { setcookie("tshippingFreeNews", "soccer"); $tshippingFreeNews = "soccer"; } elseif ($tshippingFreeNewsPref == "shipping") { setcookie("tshippingFreeNews", "shipping"); $tshippingFreeNews = "shipping"; } /* Create a new Tshipping Cookie object */ $tsc = new TShipCookie; /* Check to see if the user has a cookie */ $member_id = $tsc->checkCookie($t_ship_cookie, $db); # ########################################################################## # # printDerivedData # # ########################################################################## # function printDerivedData ($cargotype, $cargo) { global $db; /* Print the top of the html output page and the start of the table */ printTableTop($cargotype); /* Need to get all the data from the saved journey info which belongs to * derived data set for this particular cargo type and cargo. Will need to * get data from more than one table. */ $cargo = urldecode($cargo); /* dodgy hack to output only coal instead of 'coal' and 'coal (saf)' for Bill 1/9/00 - Aydin */ if ($cargo == "COAL") { # $cargostr = "(t2.cargo ~* 'COAL' OR t2.cargo ~* 'COAL (Saf)')"; $cargostr = "(t2.cargo = 'COAL' OR t2.cargo = 'COAL (Saf)')"; } else { # $cargostr = "t2.cargo ~* '$cargo'"; $cargostr = "t2.cargo = '$cargo'"; } $query = "SELECT t1.*, t2.trans_id FROM saved_general_info t1, saved_cargo_info t2, frp_priorities p WHERE t1.member_id = 0 AND t1.type = '$cargotype' AND $cargostr AND t1.trans_id = t2.trans_id AND t1.trans_id = p.trans_id ORDER BY p.priority"; $sth = pg_exec($db, $query); $row = 0; $rows = $sth != FALSE ? PG_NUMROWS($sth) : 0; // Go through the derived data set while ($row < $rows) { /* Get the data from the general table */ $data = pg_fetch_object ($sth, $row); /* Need to get the rest of the data (with this trans_id) from the other tables * start with the journey table */ //$query = "SELECT * FROM saved_journey_info WHERE trans_id = $data->trans_id"; $query = "SELECT j.fr_spot, j.fr_2, j.fr_3, j.fr_4, tdd.tcr_spot, tdd.tcr_2, tdd.tcr_3, tdd.tcr_4 FROM saved_journey_info j, derived_data_tcr_data tdd WHERE j.trans_id = $data->trans_id AND tdd.date_stamp = 'today' AND j.tcr_ref = tdd.id"; $sth2 = pg_exec($db, $query); /* Get the data from the port table */ $query = "SELECT * FROM saved_port_info WHERE trans_id = $data->trans_id ORDER BY num ASC"; $sth3 = pg_exec($db, $query); /* Get the data from the cargo table */ $query = "SELECT * FROM saved_cargo_info WHERE trans_id = $data->trans_id"; $sth4 = pg_exec($db, $query); /* Now need to print the data out. */ printTableRow($cargotype, $data, $sth2, $sth3, $sth4); $row++; } // end while /* output the datestamp of the latest output to give an indication of last updated date... */ $datedb = pg_exec($db, "SELECT to_char(datestamp,'Dy DD Mon YYYY, HH:MIam') AS date FROM saved_journey_info LIMIT 1"); $date_data = pg_fetch_object($datedb, 0); $datestamp = $date_data->date; echo "
|
# ########################################################################## # # printTableTop # # ########################################################################## # function printTableTop ($cargo_type) { global $cargo; $today = getdate(); $mon = $today[mon]; // subtract one so the algorithm (below) is the same as the perl version (where jan=0) $mon--; $months = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); if (($mon>=3) && ($mon<=5)) { $fwd1 = 6; $fwd2 = 9; $fwd3 = 0; } else if (($mon>=6) && ($mon<=8)) { $fwd1 = 9; $fwd2 = 0; $fwd3 = 3; } else if (($mon>=9) && ($mon<=11)) { $fwd1 = 0; $fwd2 = 3; $fwd3 = 6; } else if (($mon>=0) || ($mon<=2)) { $fwd1 = 3; $fwd2 = 6; $fwd3 = 9; } // Determine what additional table headings we require for either dry/wet/gas if ($cargo_type == 'dry' || $cargo_type == 'gas') { $rate = "VoyRt"; } else { $rate = "WSR"; } ?> Cargo - $val = ucfirst(strtolower($cargo)); print("$val"); ?>
[back]
|